home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / console-data.config < prev    next >
Encoding:
Text File  |  2010-12-19  |  29.3 KB  |  1,286 lines

  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. #
  6. # Package contents
  7. #
  8. $::keymaps = {};
  9.  
  10. # Any item named 'Standard' will be the default choice among its siblings.
  11. # Any single item ditto.
  12. # If none bears that name, declare a sibling element "default => 'his name'".
  13.  
  14. # Not perfect: the last package declaring a default will win :}
  15. # Maybe package with no default should depend on package with one ?
  16. # Lintian will have to be smart then !
  17.  
  18. # Maybe implement ratings instead of 'default' flag ?
  19.  
  20. #####KEYMAPS#####
  21. # -*- perl -*-
  22.  
  23. $::keymaps->{pc} =
  24. {
  25.     default => 'qwerty',
  26.  
  27.     'azerty' =>
  28.     {
  29.     default => 'French',
  30.     'French' =>
  31.     {
  32.         default => 'Same as X11 (latin 9)',
  33.         'Same as X11 (latin 9)' => { 'Standard' => 'fr-latin9', },
  34.         'Apple USB' => { 'Standard' => 'mac-usb-fr', },
  35.  
  36.     },
  37.     'Belgian' => # needs confirm
  38.     {
  39.         'Standard' =>
  40.         {
  41.         'Standard' => 'be2-latin1',
  42.         },
  43.         'Wang' => { 'Standard' => 'wangbe', },
  44.         'Apple USB' => { 'Standard' => 'mac-usb-be', },
  45.     },
  46.     },
  47.  
  48.     'dvorak' => # needs confirm
  49.     {
  50.     default => 'Unknown',
  51.     'Unknown' =>
  52.     {
  53.         'Standard' =>
  54.         {
  55.         'Standard' => 'dvorak',
  56.         'ANSI' => 'ANSI-dvorak',
  57.         'Dvorak German' => 'dvorak-de',
  58.         'Dvorak French' => 'dvorak-fr',
  59.         'Dvorak French Bepo' => 'dvorak-fr-bepo',
  60.         'Dvorak French Bepo (UTF8)' => 'dvorak-fr-bepo-utf8',
  61.         'Dvorak Russian' => 'dvorak-ru',
  62.         'Dvorak United Kingdom' => 'dvorak-uk',
  63.         'With French and Spanish accents' => 'pc-dvorak-latin1',
  64.         'Dvorak Classic' => 'dvorak-classic',
  65.         'Dvorak Lisp machine' => 'dvorak-lisp',
  66.         },
  67.         'Left single-handed' => { 'Standard' => 'dvorak-l', },
  68.         'Right single-handed' => { 'Standard' => 'dvorak-r', },
  69.         'Apple USB' => { 'Standard' => 'mac-usb-dvorak', },
  70.     },
  71.     },
  72.  
  73.     'fgGIod' =>
  74.     {
  75.     default => 'Turkish',
  76.     'Turkish' => 
  77.     {
  78.         'Standard' =>
  79.         {
  80.         default => 'F Layout',
  81.         'F Layout' => 'trf',
  82.         'F Layout with Unicode' => 'trfu',
  83.         },
  84.     },
  85.     },
  86.  
  87.     'qwerty' =>
  88.     {
  89.     default => 'US american',
  90.     'US american' =>
  91.     {
  92.         'Standard' =>
  93.         {
  94.         'Standard' => 'us',
  95.         'With latin1' => 'us-latin1',
  96.         'US International (ISO 8859-1)' => 'us-intl.iso01',
  97.         'US International (ISO 8859-15)' => 'us-intl.iso15',
  98.         'Lisp Machine' => 'lisp-us',
  99.         },
  100.         'Apple USB' =>
  101.         {
  102.         'Standard' => 'mac-usb-us',
  103.         },
  104.     },
  105.     'British' =>
  106.     {
  107.         'Standard' => { 'Standard' => 'uk', },
  108.         'Apple USB' => { 'Standard' => 'mac-usb-uk', },
  109.     },
  110.     'Bulgarian' =>
  111.     {
  112.         'Standard' => { 'Standard' => 'bg', },
  113.         'CP 1251 coding' => { 'Standard' => 'bg-cp1251' },
  114.     },
  115.     'Byelorussian' =>
  116.     { 
  117.         'Standard' => { 'Standard' => 'by' },
  118.     },
  119.     'Brazilian' =>        
  120.     {
  121.         'BR-Latin1' => { 'Standard' => 'br-latin1', },
  122.         'Standard' => 
  123.         { 
  124.         default => 'Standard ABNT2',
  125.         'Standard ABNT2' => 'br-abnt2', 
  126.         },
  127.     },
  128.     'Canadian' => 
  129.     {
  130.         default => 'ca-multi',
  131.         'Multilingual' => { 'Standard' => 'ca-multi', },
  132.         'French' => { 'Standard' => 'cf', },
  133.         'English' => { 'Standard' => 'us', },
  134.     },
  135.     'Czech' => # needs confirm
  136.     {
  137.         'Standard' =>
  138.         {
  139.         'Standard' => 'cz-lat2',
  140.         'Programmer' => 'cz-lat2-prog',
  141.         'US Layout' => 'cz-us-qwerty',
  142.         },
  143.     },
  144.     'Danish' => # needs confirm
  145.     {
  146.         'Standard' =>
  147.         {
  148.         'Standard' => 'dk',
  149.         'Dead keys' => 'dk-latin1',
  150.         'Apple USB' => 'mac-usb-dk-latin1',
  151.         },
  152.     },
  153.     'Spanish' => # needs confirm
  154.     {
  155.         'Standard' =>
  156.         {
  157.         'Standard' => 'es',
  158.         'CP850' => 'es-cp850',
  159.         },
  160.         'Apple USB' =>
  161.         {
  162.         'Standard' => 'mac-usb-es',
  163.         },
  164.     },
  165.     'Estonian' => # needs confirm
  166.     {
  167.         'Standard' =>
  168.         {
  169.         'Standard' => 'et',
  170.         'No dead keys' => 'et-nodeadkeys',
  171.         },
  172.     },
  173.     'Finnish' => # needs confirm (cf swedish ?)
  174.     {
  175.         'Standard' => { 'Standard' => 'fi-latin1', },
  176.         'Old (obsolete)' => { 'Standard' => 'fi', },
  177.         'Apple USB' => { 'Standard' => 'mac-usb-fi-latin1', },
  178.     },
  179.     'Polish' => 
  180.     {
  181.         'Standard' =>
  182.         {
  183.         default => 'Diacritics with AltGr and Alt',
  184.         'AltGr only diacritics' => 'pl1',
  185.         'Diacritics with AltGr and Alt' => 'pl',
  186.         },
  187.     },
  188.     'Greek' => 
  189.     {
  190.         'Standard' =>
  191.         {
  192.         'Standard' => 'gr',
  193.         'gr-pc' => 'gr-pc',
  194.         },
  195.     },
  196.     'Italian' => 
  197.     {
  198.         'Standard' =>
  199.         {
  200.         'Standard' => 'it',
  201.         'it2' => 'it2',
  202.         'IBM' => 'it-ibm',
  203.         },
  204.     },
  205.     'Lithuanian' =>
  206.     {
  207.         'Standard' =>
  208.         {
  209.         default => 'latin4',        
  210.         'latin4' => 'lt.l4',
  211.         'unicode' => 'lt',
  212.         },
  213.     },
  214.     'Latvian' =>
  215.     {
  216.         'Standard' =>
  217.         {
  218.         default => 'latin4',
  219.         'latin4' => 'lv-latin4',
  220.         'latin7' => 'lv-latin7',
  221.         },
  222.     },
  223.     'Norwegian' => # needs confirm
  224.     {
  225.         'Standard' =>
  226.         {
  227.         'Standard' => 'no',
  228.         'latin1' => 'no-latin1',
  229.         },
  230.     },
  231.     'Japanese' => # needs confirm
  232.     {
  233.         'Standard' => { 'Standard' => 'jp106', },
  234.         'PC 110' => { 'Standard' => 'pc110', },
  235.     },
  236.     'Dutch' =>
  237.     {
  238.         'Standard' => { 'Standard' => 'nl', },
  239.     },
  240.     'Hebrew' => 
  241.     {
  242.         'Standard' => 
  243.         {
  244.         'Standard' =>  'il',
  245.         'Phonetic' =>   'il-phonetic',
  246.         'il-Heb'   => 'il-heb',
  247.         'Old Phonetic'   => 'hebrew',
  248.         },
  249.     },
  250.     'Hungarian' =>
  251.     {
  252.         'Standard' => { 'Standard' => 'hu101', },
  253.     },
  254.     'Icelandic' =>
  255.     {
  256.         'Standard' => { 'Standard' => 'is-latin1', 
  257.                         'US' => 'is-latin1-us' 
  258.               },
  259.     },
  260.     'Kirghiz' =>
  261.     {
  262.         'Standard' => 
  263.         { 
  264.         default => 'unicode',
  265.         'unicode' => 'kg', 
  266.         },
  267.     },
  268.     'Latin American' =>
  269.     {
  270.         'Standard' => { 'Standard' => 'la-latin1', },
  271.     },
  272.     'Macedonian' =>
  273.     {
  274.         'Standard' => 
  275.         { 
  276.         default => 'unicode',
  277.         'unicode' => 'mk', 
  278.         },
  279.     },
  280.     'Portugese' => 
  281.     {
  282.         'Standard' =>
  283.         {
  284.         'Standard' => 'pt-latin1',
  285.         'Old keymap' => 'pt-old',
  286.         },
  287.     },
  288.     'Romanian' =>
  289.     {
  290.         'Standard' => 
  291.         {
  292.         'Standard' => 'ro',
  293.         'Academic' => 'ro-academic',
  294.         'With comma' => 'ro-comma',
  295.         },
  296.     },
  297.     'Russian' =>
  298.     {
  299.  
  300.         'Standard' =>
  301.         {
  302.         default =>     'KOI8-R (RightAlt)',
  303.         'KOI8-R (RightAlt)' => 'ru1',
  304.         'KOI8-R (RightCtrl)' => 'ru',
  305.         'KOI8-R (102 Keys)' => 'ru3',
  306.         'KOI8-R (105 Keys)' => 'ru4',
  307.         'KOI8-R (MS Cyrillic Layout)' => 'ru-ms',
  308.         'KOI8-R (Yawerty Layout)' => 'ru-yawerty',
  309.         'CP-1251 (1)' => 'ru-cp1251',
  310.         'CP-1251 (2)' => 'ru_win',
  311.         'CP-866' => 'ru2',
  312.         },
  313.     },
  314.     'Serbian' =>
  315.     {
  316.         'Standard' => {'Standard' => 'sr-cy', },
  317.     },    
  318.     'Swedish' => # needs confirm (cf finnish ?)
  319.     {
  320.         'Standard' => { 'Standard' => 'se-latin1', },
  321.         'Apple USB' => { 'Standard' => 'mac-usb-se', },
  322.     },
  323.     'Slovak' =>
  324.     {
  325.         'Standard' =>
  326.         {
  327.         'Standard' => 'sk-qwerty',
  328.         'Programmer' => 'sk-prog',
  329.         'Alternate programmer' => 'sk-prog-qwerty',
  330.         },
  331.     },
  332.     'Thai' =>
  333.     {
  334.         'Standard' => {'Standard' => 'th-tis', },
  335.     },
  336.     'Turkish' => # needs confirm
  337.     {
  338.         'Standard' =>
  339.         {
  340.         default => 'Q Layout',
  341.         'Q Layout' => 'trq',
  342.         'Q Layout with Unicode' => 'trqu',
  343.         'Alternate' => 'tralt',
  344.         },
  345.     },
  346.     'Ukrainian' => 
  347.     {
  348.         'Standard' =>
  349.         {
  350.         default => 'Standard (koi8u)' ,
  351.         'Standard (koi8u)' => 'ua',
  352.         'WS' => 'ua-ws',
  353.         'unicode' => 'ua-utf',
  354.         'WS - unicode' => 'ua-utf-ws',
  355.         'Alternate' => 'uaw',
  356.         'Alternate - unicode' => 'uaw_uni',
  357.         },
  358.     },
  359.     },
  360.  
  361.     'qwertz' =>
  362.     {
  363.     default => 'German',
  364.     'Swiss' => # needs confirm
  365.     {
  366.         default => 'German',
  367.         'French' =>
  368.         {
  369.         'Standard' => 'fr_CH',
  370.         'latin1' => 'fr_CH-latin1',
  371.         'Apple USB' => 'mac-usb-fr_CH-latin1',
  372.         },
  373.         'German' =>
  374.         {
  375.         'Standard' => 'sg',
  376.         'latin1' => 'sg-latin1',
  377.         'latin1-lk450' => 'sg-latin1-lk450',
  378.         'Apple USB' => 'mac-usb-de_CH',
  379.         },
  380.     },
  381.     'German' => # needs confirm
  382.     {
  383.         'Standard' =>
  384.         {
  385.         default => 'de-latin1',
  386.         'latin1' => 'de-latin1',
  387.         'latin1 - no dead keys' => 'de-latin1-nodeadkeys',
  388.         'Programmer' => 'de',
  389.         },
  390.         'Apple USB' =>
  391.         {
  392.         default => 'latin1',
  393.         'latin1' => 'mac-usb-de-latin1',
  394.         'latin1 - no dead keys' => 'mac-usb-de-latin1-nodeadkeys',
  395.         },
  396.     },
  397.     'Slovak' =>
  398.     {
  399.         'Standard' =>
  400.         {
  401.         'Standard' => 'sk-qwertz',
  402.         'Programmer' => 'sk-prog-qwertz',
  403.         },
  404.     },
  405.     'Czech' =>
  406.     {
  407.         'Standard' => { 'Standard' => 'cz-us-qwertz', },
  408.     },
  409.     'Polish' =>
  410.     {
  411.         'Standard' => { 'Standard' => 'pl-qwertz', },
  412.     },
  413.     'Hungarian' =>
  414.     {
  415.         'Standard' => { 'Standard' => 'hu', },
  416.     },
  417.     'Slovene' =>
  418.     {
  419.         'Standard' => { 'Standard' => 'slovene', },
  420.     },
  421.     'Croat' =>
  422.     {
  423.         'Standard' => { 'Standard' => 'croat', },
  424.     },
  425.     'Serbian' =>
  426.     {
  427.         'Standard' => { 'Standard' => 'sr', },
  428.     },
  429.     },
  430.  
  431. };
  432.  
  433. $::keymaps->{sparc} =
  434. {
  435.     default => 'Type 5',
  436.     'Type 6' =>
  437.     {
  438.     default => 'British',
  439.     'British' =>
  440.     {
  441.         'Standard' => { 'Standard' => 'sunt6-uk', },
  442.     },
  443.     },
  444.     'Type 5' =>
  445.     {
  446.     default => 'US american',
  447.     'French' =>
  448.     {
  449.         'Standard' => { 'Standard' => 'sunt5-fr-latin1', },
  450.     },
  451.     'German' =>
  452.     {
  453.         'Standard' => { 'Standard' => 'sunt5-de-latin1', },
  454.     },
  455.     'Spanish' =>
  456.     {
  457.         'Standard' => { 'Standard' => 'sunt5-es', },
  458.     },
  459.     'Finnish' =>
  460.     {
  461.         'Standard' => { 'Standard' => 'sunt5-fi-latin1', },
  462.     },
  463.     'Russian' =>
  464.     {
  465.         'Standard' => { 'Standard' => 'sunt5-ru', },
  466.     },
  467.     'Turkish' =>
  468.     {
  469.         'Standard' => { 'Standard' => 'sunt5-trqalt' },
  470.     },
  471.     'British' =>
  472.     {
  473.         'Standard' => { 'Standard' => 'sunt5-uk', },
  474.     },
  475.     'US american' =>
  476.     {
  477.         'Standard' => { 'Standard' => 'sunkeymap', },
  478.     },
  479.     'Japanese' =>
  480.     {
  481.         'Standard' => { 'Standard' => 'sunt5-ja', },
  482.     },
  483.     'Norwegian' =>
  484.     {
  485.         'Standard' => { 'Standard' => 'sunt5-no', },
  486.     },
  487.     },
  488.     'Type 4' =>
  489.     {
  490.     'Spanish' =>
  491.     {
  492.         'Standard' => { 'Standard' => 'sunt4-es', },
  493.     },
  494.     'Japanese' =>
  495.     {
  496.         'Standard' => { 'Standard' => 'sunt4-ja', },
  497.     },
  498.     'Norwegian' =>
  499.     {
  500.         'Standard' => { 'Standard' => 'sunt4-no-latin1', },
  501.     },
  502.     'Finnish' =>
  503.     {
  504.         'Standard' => { 'Standard' => 'sunt4-fi-latin1', },
  505.     },
  506.     },
  507.     'dvorak' =>
  508.     {
  509.     'Unknown' =>
  510.     {
  511.         'Standard' => { 'Standard' => 'sundvorak', },
  512.     },
  513.     },
  514.     'Unknown (Polish)' =>
  515.     {
  516.     'Polish' =>
  517.     {
  518.         'Standard' => { 'Standard' => 'sun-pl', },
  519.     },
  520.     },
  521. };
  522.  
  523. $::keymaps->{atari} =
  524. {
  525.     'Unknown' =>
  526.     {
  527.     default => 'US american',
  528.     'German' =>
  529.     {
  530.         'Standard' =>
  531.         {
  532.         'Standard' => 'atari-de',
  533.         'With dead keys' => 'atari-de-deadkeys',
  534.         'Emacs-like' => 'atari-de-emacs',
  535.         },
  536.     },
  537.     'Swedish' =>
  538.     {
  539.         'Standard' =>
  540.         {
  541.         'Standard' => 'atari-se',
  542.         'With dead keys' => 'atari-se-deadkeys',
  543.         },
  544.     },
  545.     'British' =>
  546.     {
  547.         'Standard' =>
  548.         {
  549.         'Standard' => 'atari-uk',
  550.         'With dead keys' => 'atari-uk-deadkeys',
  551.         },
  552.     },
  553.     'US american' =>
  554.     {
  555.         'Standard' =>
  556.         {
  557.         'Standard' => 'atari-us',
  558.         'With dead keys' => 'atari-us-deadkeys',
  559.         },
  560.     },
  561.     },
  562. };
  563.  
  564. $::keymaps->{amiga} =
  565. {
  566.     'Unknown' =>
  567.     {
  568.     default => 'US american',
  569.     'German' =>
  570.     {
  571.         'Standard' => { 'Standard' => 'amiga-de', },
  572.     },
  573.     'Spanish' =>
  574.     {
  575.         'Standard' => { 'Standard' => 'amiga-es', },
  576.     },
  577.     'French' =>
  578.     {
  579.         'Standard' => { 'Standard' => 'amiga-fr', },
  580.     },
  581.     'Italian' =>
  582.     {
  583.         'Standard' => { 'Standard' => 'amiga-it', },
  584.     },
  585.     'Swedish' =>
  586.     {
  587.         'Standard' => { 'Standard' => 'amiga-se', },
  588.     },
  589.     'Swiss' =>
  590.     {
  591.         'German' => { 'Standard' => 'amiga-sg', },
  592.     },
  593.     'US american' =>
  594.     {
  595.         'Standard' => { 'Standard' => 'amiga-us', },
  596.     },
  597.     },
  598. };
  599.  
  600. $::keymaps->{mac} =
  601. {
  602.     'Unknown' =>
  603.     {
  604.     default => 'US american',
  605.     'German' =>
  606.     {
  607.         'Standard' =>
  608.         {
  609.         'Standard' => 'mac-de2-ext',
  610.         'iBook' => 'mac-ibook-de',
  611.         'iBook with dead keys' => 'mac-ibook-de-deadkeys',
  612.         'MacBook' => 'mac-macbook-de',
  613.         #'No dead keys (broken)' => 'mac-de-latin1-nodeadkeys', # buggy
  614.         },
  615.     },
  616.     'British' =>
  617.     {
  618.         'Standard' =>
  619.         { 
  620.         'Standard' => 'mac-uk',
  621.         'iBook2' => 'ibook2-uk', 
  622.         },
  623.     },
  624.     'French' =>
  625.     {
  626.         'Standard' =>
  627.         {
  628.         'Standard' => 'mac-fr3',
  629.         'New' => 'mac-fr',
  630.         'Extended' => 'mac-fr-ext',
  631.         'MacBook' => 'mac-macbook-fr',
  632.         'Swiss' => 'mac-fr_CH-latin1',
  633.         'Alternate' => 'mac-fr2-ext',
  634.         },
  635.     },
  636.     'Polish' =>
  637.     {
  638.         'Standard' => 
  639.         { 
  640.         'Standard' => 'mac-pl_m-ext',
  641.         # Supply ext1 variant in pkg for ADB freaks; don't offer it here as 
  642.         # ADB is deprecated
  643.         },
  644.     },
  645.     'Portuguese' => 
  646.     { 
  647.         'Standard' =>  { 'Standard' => 'mac-pt-latin1' },
  648.         'Apple USB' => { 'Standard' => 'mac-usb-pt-latin1' },
  649.     },        
  650.     'Spanish' => 
  651.     {
  652.         'Standard' => {  'Standard' => 'mac-es' },
  653.     },
  654.     'Finnish' =>
  655.     {
  656.         'Standard' => { 'Standard' => 'mac-fi-latin1' },
  657.     },
  658.     'Italian' =>
  659.     {
  660.         'Standard' =>  
  661.         { 'Standard' => 'mac-it' , 
  662.           'iBook' => 'ibook-it',
  663.           'iBook (alternate)' => 'ibook2-it'
  664.         },
  665.         'Apple USB' => { 'Standard' => 'mac-usb-it' },
  666.     },
  667.     'US american' =>
  668.     {
  669.         'Standard' =>
  670.         {
  671.         'Standard' => 'mac-us-std',
  672.         'Extended' => 'mac-us-ext',
  673.         'New' => 'mac-us',
  674.         #Dvorak' => 'mac-us-dvorak', # buggy
  675.         'Dvorak' => 'mac-dvorak',
  676.         },
  677.     },
  678.     },
  679. };
  680.  
  681. $::obsolete_keymaps = (
  682.                [ 'pc', 'qwerty', 'Canadadian' ],
  683.                );
  684.  
  685. # END OF DATAPACKAGE-SPECIFIC PART
  686. # BELOW THIS LINE IS THE GENERIC PART
  687.  
  688. # This a preliminary debconf script for console-related data.
  689. # (c) 1999-2000, Yann Dirson <dirson@debian.org>
  690.  
  691. # It has the following limitations that should be addressed:
  692. # - only handles keymap configuration (ie, only does part of kbdconfig's job)
  693. # - does not allow testing keymap before accepting it (REGRESSION).
  694. # - does not allow reloading a default keymap (REGRESSION).
  695.  
  696. use Debconf::Client::ConfModule ':all';
  697.  
  698. die "Syntax error: no argument" if ($#ARGV < 0);
  699.  
  700. #####COMMON#####
  701. # -*- perl -*-
  702.  
  703. use vars qw( $obsolete_keymaps );
  704.  
  705. # Subarches
  706. # FIXME: not done
  707. # Issues:
  708. # * ppc issues not fully asserted yet
  709. # * /proc/hardware, which only exists on m68k and ppc, seems to be
  710. #   an OPTION while configuring the kernel !
  711. #   Any fallback when it's not there ?
  712. # * USB set of keymap should contain what ? mac ? pc ? subset of those ?
  713.  
  714. # SUBARCH    KEYMAP SET    DETECTION
  715. # m68k/atari    atari        "Model: Atari"
  716. # m68k/amiga    amiga        "Model: Amiga"
  717. # m68k/mac    mac        "Model: Macintosh"
  718. # m68k/mvme    pc        "Model: Motorola"
  719. # m68k/bvme    pc        "Model: BVME[46]000"
  720. # m68k/{sun,apollo,next,q40,hp300} Not supported by Debian
  721.  
  722. # ppc/apus    amiga        "machine: Amiga"
  723. # ppc/chrp    pc,mac        "machine: CHRP"
  724. # ppc/pmac    mac        "machine: PowerMac|[Pp]ower[Bb]ook*|Power|iMac*|PowerMac1*"
  725. # ppc/prep    pc        "machine: PReP"
  726. # ppc/{bbox,mbx,ppc64,82xx,8xx} Not yet supported by Debian
  727.  
  728. # arm/*        pc        (refered to as 'arm' only)
  729.  
  730. sub guess_arch {
  731.   my ($defs) = @_;
  732.  
  733.   my $arch = `dpkg --print-architecture`;
  734.   chomp $arch;
  735.  
  736.   # Overrides for testing:
  737.   #     $arch = 'powerpc';
  738.   #     $arch = 'm68k';
  739.  
  740.   if (($arch eq 'powerpc') || ($arch eq 'm68k')) {
  741.     my $subarch;
  742.     if ($arch eq 'powerpc') {
  743.       my $line = `sed -n 's/^machine.*: //p' /proc/cpuinfo`;
  744.       chomp $line;
  745.       abort ($defs, "No \"machine\" field in /proc/cpuinfo") if $line eq '';
  746.       $subarch = lc $line;
  747.     } elsif ($arch eq 'm68k') {
  748.       my $line = `sed -n 's/^Model.*://p' /proc/hardware`;
  749.       chomp $line;
  750.       abort ($defs, "No \"Model\" field in /proc/hardware") if $line eq '';
  751.       $subarch = lc $line;
  752.     }
  753.     chomp($subarch);
  754.     $subarch =~ s/^\s*//;
  755.     $subarch = 'amiga'    if $subarch =~ m/amiga/;
  756.     $subarch = 'chrp'    if $subarch =~ m/chrp/;
  757.     $subarch = 'prep'    if $subarch =~ m/prep/;
  758.     $subarch = 'mac'    if $subarch =~ m/macintosh|powermac|powerbook|power|imac|powermac1/;
  759.     $subarch = 'atari'    if $subarch =~ m/atari/;
  760.     $subarch = 'mvme'    if $subarch =~ m/motorola/;
  761.     $subarch = 'bvme'    if $subarch =~ m/bvme/;
  762.  
  763.     $arch = "$arch/$subarch";
  764.   }
  765.  
  766.   # Overrides for testing:
  767.   #     $arch = 'sparc';
  768.   #     $arch = 'powerpc/mac';
  769.   #     $arch = 'powerpc/chrp';
  770.   #     $arch = 'm68k/amiga';
  771.   #     $arch = 'alpha';
  772.  
  773.   return $arch;
  774. }
  775.  
  776. sub abort {
  777.   my ($defs, $msg) = @_;
  778.   print STDERR "Debconf module aborted ($msg) - using old config mechanism.\n";
  779. #  fset_default($defs);
  780.   exit 0;
  781. }
  782.  
  783. sub correctname($) {
  784.   my ($string) = @_;
  785.  
  786.   $string = lc $string;
  787.   $string =~ s/[^a-z0-9+\-\.\/]/_/g;
  788.  
  789.   return $string;
  790. }
  791.  
  792. # BELOW THIS LINE IS STUFF FOR ALL KEYMAP PROVIDERS
  793.  
  794. $::keymap_defs = {
  795.           'prefix' => 'console-data/keymap/',
  796.           'toplevel' => 'family',
  797.           'sublevels' => [
  798.                   'layout',
  799.                   'variant',
  800.                   'keymap',
  801.                  ],
  802.           'allitems' => $::keymaps,
  803.           'obsolete' => $::obsolete_keymaps,
  804.           'archsets' => {
  805.                  'i386' => [ 'pc' ],
  806.                  #                   'hurd-i386' => [ 'pc' ],
  807.                  'sparc' => [ 'sparc' ],
  808.                  'alpha' => [ 'pc' ],
  809.                  'arm' => [ 'pc' ],
  810.                  'arm/riscpc' => [ 'pc' ],
  811.                  'mips' => [ 'pc' ],
  812.                  'm68k/atari' => [ 'atari' ],
  813.                  'm68k/amiga' => [ 'amiga' ],
  814.                  'm68k/mac' => [ 'mac' ],
  815.                  'm68k/mvme' => [ 'pc' ],
  816.                  'm68k/bvme' => [ 'pc' ],
  817.                  'powerpc/amiga' => [ 'amiga' ], # apus
  818.                  'powerpc/chrp' => [ 'pc', 'mac' ],
  819.                  'powerpc/mac' => [ 'pc' ],
  820.                  'powerpc/prep' => [ 'pc' ],
  821.                  'amd64' => [ 'pc' ],
  822.                 },
  823.          };
  824.  
  825. # Layout of questions is:
  826. #
  827. # console-data/keymap/
  828. #   /family
  829. #   /azerty/
  830. #     /layout
  831. #     /french/
  832. #       /variant
  833. #       /without euro/
  834. #         /keymap
  835.  
  836. # FIXME: maybe use eg. country codes in storage, and translate into
  837. # localized string when needed ?
  838.  
  839. sub declare_keymaps {
  840.   my ($defs) = @_;
  841.  
  842.   foreach my $kbdarch (@{$defs->{archsets}->{guess_arch($defs)}}) {
  843.     declare_families ($defs, $defs->{allitems}->{$kbdarch}, $defs->{prefix});
  844.   }
  845. }
  846.  
  847. # Maybe set a default choice if none already set
  848. sub maybe_set_default_choice {
  849. #    my ($question, $default) = @_;
  850. #    (my $ret, my $seen) = fget ($question, 'seen');
  851. #    if ($seen eq 'false') {
  852. #      my $x = metaget ($question, 'value') ;
  853. #      print STDERR " $question is #$x# ";
  854. #    }    
  855. #set ($question, $default) if $seen eq 'false';
  856. }
  857.  
  858. #
  859. # Clear obsolete entries from the database,
  860. # Tidy up this ugly hack somehow
  861. sub clear_cruft {
  862.     my ($version) = @_;
  863.     my $ret = 0;
  864.     my $val = '';
  865.     if ($version eq '') {
  866.         $version='0';
  867.     }
  868.     my $x=system("dpkg --compare-versions $version lt 0.7.25");
  869.     if ($x eq 0 ) {
  870.         unregister ('console-data/keymap/full');
  871.         my ($ret, $val) = metaget ('console-data/keymap/azerty/french/variant', 'value');
  872.         if ($val eq 'With Euro (latin 0)') {
  873.             set ('console-data/keymap/azerty/french/variant','With Euro (latin 9)');
  874.         }
  875.         subst ('console-data/keymap/azerty/french/variant', 'choices',
  876.             'Apple USB, PC keyboard (non-US 102 keys), Same as X11 (latin 1), With Euro (latin 9)');
  877.     }
  878.     # The speakup keymaps were removed from console-data in sarge
  879.     ($ret, $val) = get ('console-data/keymap/full');
  880.     set ('console-data/keymap/full', 'us') if ($val eq  "speakup");
  881.     set ('console-data/keymap/full', 'lt') if ($val eq "speakup-lt");
  882.     my $lith_keymap = 'console-data/keymap/qwerty/lithuanian/standard/keymap';
  883.     ($ret, $val) = get ($lith_keymap);
  884.     set ($lith_keymap, 'latin4') if ($val eq "Speakup");
  885.     subst ($lith_keymap, 'choices', 'latin4, unicode');
  886.     my $us_keymap = 'console-data/keymap/qwerty/us_american/standard/keymap';
  887.     ($ret, $val) = get ($us_keymap);
  888.     set ($us_keymap, 'standard') if ($val eq "Speakup");
  889.     subst ($us_keymap, 'choices', 
  890.         'Standard, US International (ISO 8859-1), US International (ISO 8859-15), With latin1');
  891. }
  892.  
  893.  
  894. sub find_default {
  895.   my ($leveldefs, $question) = @_;
  896.  
  897.   if (defined $leveldefs->{default}) {
  898.     my $def = $leveldefs->{default};
  899.     # FIXME: not really deleted ?!
  900.     delete $leveldefs->{default};
  901.     return $def;
  902.   } elsif (defined $leveldefs->{Standard}) {
  903.     return 'Standard';
  904. #  } elsif (scalar(keys %{$leveldefs}) == 1) {
  905.   } else {
  906.     printf STDERR "No default for $question - picking one\n";
  907.     $::warned = 1;
  908.     return (keys %{$leveldefs})[0];
  909.   }
  910. }
  911.  
  912. sub declare_families {
  913.   my ($defs, $familydefs, $prefix) = @_;
  914.   my $familyquestion = $prefix . $defs->{toplevel};
  915.   $familyquestion = correctname $familyquestion;
  916.  
  917.   # There is only one family question, never need to register more
  918.  
  919.   my ($ret, $families) = metaget ($familyquestion, 'choices');
  920.   my @families = split (/, */, $families);
  921.  
  922.   # take default entry into account
  923.   my $default = find_default ($familydefs, $familyquestion);
  924.  
  925.   foreach my $family (keys %{$familydefs}) {
  926.     # add family if not declared yet
  927.     push (@families, $family) unless grep { $_ eq $family } @families;
  928.  
  929.     declare_layouts ($defs,
  930.              $familydefs->{$family},
  931.              $prefix . $family . '/');
  932.   }
  933.  
  934.   # Update list of available families
  935.   subst ($familyquestion, 'choices', join (", ", sort @families));
  936.   maybe_set_default_choice ($familyquestion, $default);
  937. }
  938.  
  939. sub declare_layouts {
  940.   my ($defs, $layoutdefs, $prefix) = @_;
  941.   my $layoutquestion = $prefix . $defs->{sublevels}->[0];
  942.   $layoutquestion = correctname $layoutquestion;
  943.  
  944.   # create if needed
  945.   my ($ret) = get ($layoutquestion);
  946.   register ($defs->{prefix} . 'template/' . $defs->{sublevels}->[0],
  947.         $layoutquestion) if $ret == 10;
  948.  
  949.   ($ret, my $layouts) = metaget ($layoutquestion, 'choices');
  950.   my @layouts = split (/, */, $layouts);
  951.  
  952.   # take default entry into account
  953.   my $default = find_default ($layoutdefs, $layoutquestion);
  954.  
  955.   foreach my $layout (keys %{$layoutdefs}) {
  956.     # add layout if not declared yet
  957.     push (@layouts, $layout) unless grep { $_ eq $layout } @layouts;
  958.  
  959.     declare_kbdvariants ($defs,
  960.              $layoutdefs->{$layout},
  961.              $prefix . $layout . '/');
  962.   }
  963.   # Update list of available layouts
  964.   subst ($layoutquestion, 'choices', join (", ", sort @layouts));
  965.   # Maybe set default choice
  966.   maybe_set_default_choice ($layoutquestion, $default);
  967. }
  968.  
  969. sub declare_kbdvariants {
  970.   my ($defs, $kbdvariantdefs, $prefix) = @_;
  971.   my $kbdvariantquestion = $prefix . $defs->{sublevels}->[1];
  972.   $kbdvariantquestion = correctname $kbdvariantquestion;
  973.  
  974.   # create if needed
  975.   my ($ret) = get ($kbdvariantquestion);
  976.   register ($defs->{prefix} . 'template/' . $defs->{sublevels}->[1],
  977.         $kbdvariantquestion) if $ret == 10;
  978.  
  979.   ($ret, my $kbdvariants) = metaget ($kbdvariantquestion, 'choices');
  980.   my @kbdvariants = split (/, */, $kbdvariants);
  981.  
  982.   # take default entry into account
  983.   my $default = find_default ($kbdvariantdefs, $kbdvariantquestion);
  984.  
  985.   foreach my $kbdvariant (keys %{$kbdvariantdefs}) {
  986.     # add kbdvariant if not declared yet
  987.     push (@kbdvariants, $kbdvariant) unless grep { $_ eq $kbdvariant } @kbdvariants;
  988.  
  989.     declare_mapvariants ($defs,
  990.              $kbdvariantdefs->{$kbdvariant},
  991.              $prefix . $kbdvariant . '/');
  992.   }
  993.   # Update list of available kbdvariants
  994.   subst ($kbdvariantquestion, 'choices', join (", ", sort @kbdvariants));
  995.   # Maybe set default choice
  996.   maybe_set_default_choice ($kbdvariantquestion, $default);
  997. }
  998.  
  999. sub declare_mapvariants {
  1000.   my ($defs, $mapvariantdefs, $prefix) = @_;
  1001.   my $mapvariantquestion = $prefix . $defs->{sublevels}->[2];
  1002.   $mapvariantquestion = correctname $mapvariantquestion;
  1003.  
  1004.   # create if needed
  1005.   my ($ret) = get ($mapvariantquestion);
  1006.   register ($defs->{prefix} . 'template/' . $defs->{sublevels}->[2],
  1007.         $mapvariantquestion) if $ret == 10;
  1008.  
  1009.   # take default entry into account
  1010.   my $default = find_default ($mapvariantdefs, $mapvariantquestion);
  1011.  
  1012.   ($ret, my $mapvariants) = metaget ($mapvariantquestion, 'choices');
  1013.   my @mapvariants = split (/, */, $mapvariants);
  1014.  
  1015.   foreach my $mapvariant (keys %{$mapvariantdefs}) {
  1016.     # add mapvariant if not declared yet
  1017.     push (@mapvariants, $mapvariant) unless grep { $_ eq $mapvariant } @mapvariants;
  1018.   }
  1019.   # Update list of available mapvariants
  1020.   subst ($mapvariantquestion, 'choices', join (", ", sort @mapvariants));
  1021.   maybe_set_default_choice ($mapvariantquestion, $default);
  1022. }
  1023.  
  1024. # handle transitions in the state machine
  1025. sub transition {
  1026.   my ($defs, $origstate, $priority, $prev, $next) = @_;
  1027.   my $newstate;
  1028.   my $ret;
  1029.   my @retval;
  1030.  
  1031.   # compute question according to state
  1032.   my $prefix = $defs->{prefix};
  1033.   my $question = $prefix . $defs->{toplevel};
  1034.   for (my $level = 0; $level < $origstate; $level ++) {
  1035.     my ($ret, $choice) = get ($question);
  1036.     $prefix = $prefix . $choice . '/';
  1037.     $question = $prefix . $defs->{sublevels}->[$level];
  1038.     $question = correctname $question;
  1039.   }
  1040.  
  1041.   ($ret) = input ($priority, $question);
  1042.   @retval = go;
  1043.   if ($retval[0] eq 30) {
  1044.       $newstate = $prev;
  1045.   } else {
  1046.     $newstate = $next;
  1047.   }
  1048.  
  1049.   return $newstate;
  1050. }
  1051.  
  1052.  
  1053. # The real config engine
  1054. sub configure {
  1055.   my ($defs) = @_;
  1056.   my $ret;
  1057.   my @retval;
  1058.  
  1059.   my $state = 0;
  1060.   # This is a simple state machine for all config items
  1061.   while ($state != 99) {
  1062.  
  1063.     #
  1064.     # Change the keymap ?
  1065.     #
  1066.  
  1067.     ($state == 0) && do {
  1068.  
  1069.       # This one has a default, we can trust it has a value
  1070.       ($ret) = input ('high', 'console-data/keymap/policy');
  1071.       if ($ret == 30) {        # if the question is not going to be asked...
  1072.      maybe_set_default_choice ('console-data/keymap/policy', "Don't touch keymaps");
  1073.       }
  1074.       @retval = go;
  1075.       if ($retval[0] eq 30) {
  1076.     set ('console-data/keymap/policy', "Don't touch keymap");
  1077.     exit 30; 
  1078.       }
  1079.  
  1080.       my $policy = get ('console-data/keymap/policy');
  1081.  
  1082.       # Ugly workaround for Bug 107700
  1083.       $policy = 'Select keymap from arch list' if
  1084.           $policy eq "console-data/keymap/policy doesn't exist";
  1085.  
  1086.       if ($policy eq 'Select keymap from arch list') {
  1087.     $state = 1;
  1088.     next;
  1089.       } elsif ($policy eq "Don't touch keymap") {
  1090.     # if the user has a bootime keymap in an old location, warn
  1091.     if (! -r '/etc/console/boottime.kmap.gz'
  1092.         and ( -r '/etc/kbd/default.kmap' or -r '/etc/kbd/default.kmap.gz' or
  1093.           -r '/etc/console-tools/default.kmap' or -r '/etc/console-tools/default.kmap.gz')) {
  1094.       input ('critical', 'console-data/keymap/ignored');
  1095.       @retval = go;
  1096.       if ($retval[0] eq "backup") {
  1097.         ($ret, my $seen) = fget ('console-data/keymap/policy', 'seen');
  1098.         if ($seen eq 'false') {
  1099.           # Hitting "back" here has no meaning mostly, but try to behave as sanely as I
  1100.           # can think of.
  1101.           exit 30;
  1102.         } else {
  1103.           next;
  1104.         }
  1105.       }
  1106.     }
  1107.  
  1108.     $state = 99;
  1109.       } elsif ($policy eq 'Keep kernel keymap') {
  1110.     $state = 99;
  1111.       } elsif ($policy eq 'Select keymap from full list') {
  1112.         my $ret;
  1113.         ($ret) = input ('high', 'console-data/keymap/full');
  1114.         if ($ret == 30) {
  1115.             $state = 99;
  1116.             next;
  1117.         }
  1118.         @retval = go;
  1119.         if ($retval[0] eq 'backup') {
  1120.            $state = 0;
  1121.         } else {
  1122.            $state = 99;
  1123.            my($full);
  1124.            ($ret, $full) = get ('console-data/keymap/full');
  1125.            if ($full) {
  1126.                set ('console-data/keymap/full', $::all_maps{$full});
  1127.            }
  1128.         }
  1129.       } else {
  1130.     die "get(console-data/keymap/policy) said $policy"
  1131.       }
  1132.     };
  1133.  
  1134.     #
  1135.     # Keymap changes
  1136.     #
  1137.  
  1138.     ($state == 1) && do {
  1139.  
  1140.     my $kstate = 0;
  1141.  
  1142.         if (guess_arch($::keymap_defs) eq 'powerpc/mac') {
  1143.             my($proc_file) = "/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes";
  1144.             if (-e $proc_file) {
  1145.                 open(KEYCODES, $proc_file);
  1146.                 my($input) = <KEYCODES>;
  1147.                 chomp($input);
  1148.                 close(KEYCODES);
  1149.                 if ($input eq "0") {
  1150.                     input ('high', 'console-data/keymap/powerpcadb');
  1151.                     @retval = go;
  1152.                     if ($retval[0] eq 'backup') {
  1153.                         $kstate = -1;
  1154.                     } else {
  1155.                         my($answer);
  1156.                         ($ret, $answer) = get ('console-data/keymap/powerpcadb');
  1157.                         if ($answer eq 'no') {
  1158.                             set ('console-data/keymap/policy', "Don't touch keymap");
  1159.                             exit;
  1160.                         }
  1161.                     }
  1162.                     if ($kstate != -1) {
  1163.                         open(KEYCODES,  "> $proc_file") || die "Cannot open $proc_file for writing!\n";
  1164.                         print KEYCODES "1";
  1165.                         close(KEYCODES);
  1166.                     }
  1167.                 }
  1168.             }
  1169.         }
  1170.  
  1171.     # This is a simple embedded state machine for keymap
  1172.     while (($kstate != 99) and ($kstate != -1)) {
  1173.       ($kstate == 0) && do { # get_family
  1174.         $kstate = transition ($defs, 0, 'high', -1, 1);
  1175.         next;
  1176.       };
  1177.  
  1178.       ($kstate == 1) && do { # get_layout
  1179.         $kstate = transition ($defs, 1, 'high', 0, 2);
  1180.         next;
  1181.       };
  1182.  
  1183.       ($kstate == 2) && do { # get_kbdvariant
  1184.         $kstate = transition ($defs, 2, 'medium', 1, 3);
  1185.         next;
  1186.       };
  1187.  
  1188.       ($kstate == 3) && do { # get_mapvariant
  1189.         $kstate = transition ($defs, 3, 'low', 2, 99);
  1190.         next;
  1191.       };
  1192.     }
  1193.  
  1194.     if ($kstate == -1) {
  1195.       $state = 0;
  1196.     } else {
  1197.       $state = 99;
  1198.     }
  1199.  
  1200.       next;
  1201.     };
  1202.  
  1203.     #
  1204.     # The default font, and SFM fallbacks
  1205.     #
  1206.  
  1207.     #
  1208.     # The default ACM ?
  1209.     #
  1210.   }
  1211. }
  1212.  
  1213. sub deconfigure {
  1214.   my ($defs) = @_;
  1215.  
  1216.   # FIXME: should deregister our entries' choices
  1217.  
  1218. #  purge;
  1219.  
  1220.   # FIXME: should run configuration of console-common afterwards (if needed ?)
  1221. }
  1222.  
  1223. # GO !
  1224.  
  1225. capb ('backup');
  1226.  
  1227. # FIXME: this should go in declare_keymaps(), but if I put it there, it
  1228. # doesn't seem to work. dunno why
  1229. sub walk;
  1230. sub walk
  1231. {
  1232.     my $h = shift;
  1233.     my @id = @_;
  1234.  
  1235.     for my $k (sort keys %$h)
  1236.     {
  1237.     next if $k eq 'default';
  1238.     if (ref $h->{$k} eq 'HASH')
  1239.     {
  1240.         walk $h->{$k}, @id, $k;
  1241.         next;
  1242.     }
  1243.     my($id) = join(' / ', @id, $k);
  1244.     $::all_maps{$id} = $h->{$k};
  1245.     }
  1246. }
  1247.  
  1248.  
  1249. walk $::keymaps;
  1250. subst ('console-data/keymap/full', 'choices', join (", ", sort keys %::all_maps));
  1251.  
  1252. if ($ARGV[0] eq 'configure') {
  1253.   $::warned = 0;
  1254.   # do not attempt declaration of empty keymap-list
  1255.   declare_keymaps ($::keymap_defs) if %{$::keymaps};
  1256.   if ($::warned) {
  1257.     printf STDERR <<EOF
  1258.  
  1259. If you have information about what choice should be the default for
  1260. the above questions which gave warnings, please mail it to
  1261. console-data\@packages.debian.org.  Thanks for your help.
  1262. EOF
  1263.   ;
  1264.   }
  1265.   # Clear cruft that may be in the database
  1266.   clear_cruft ($ARGV[1]);
  1267.   # Re-insert, as they've just been deleted... by clear_cruft()
  1268.   subst ('console-data/keymap/full', 'choices', join (", ", sort keys %::all_maps));
  1269.  
  1270.   # Don't tread on keymaps not installed via install-keymap
  1271.   my $hash = 'none';
  1272.   my $bootmap = '/etc/console/boottime.kmap.gz';
  1273.   $hash = `md5sum $bootmap | cut -f1 -d' '`  if -r $bootmap;
  1274.   chomp($hash);
  1275.   my ($ret, $val) = get ('console-data/bootmap-md5sum');
  1276.   set ('console-data/keymap/policy',"Don't touch keymap") if $val ne $hash;
  1277.  
  1278.   configure($::keymap_defs);
  1279. }
  1280. elsif ($ARGV[0] eq 'reconfigure') {
  1281.   configure($::keymap_defs);
  1282. }
  1283. elsif ($ARGV[0] eq 'X-deconfigure') {
  1284.   deconfigure($::keymap_defs);
  1285. }
  1286.